package com.qiangqiang.utils;

import com.qiangqiang.App;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Created by q on 2018/3/25.
 */
public class DbUtils {

    /**
     * 数据库的一些基本参数
     */
    private final static String DRIVER="com.mysql.jdbc.Driver";
    private final static String URL="jdbc:mysql://localhost:3306/student";
    private final static String USER="root";
    private final static String PASSWORD="root";


    /**
     * 单例的Connection
     */
    private static Connection conn;


    public static Connection getConnection() throws ClassNotFoundException, SQLException {
         if(conn==null){
             Class.forName(DRIVER);
             conn= DriverManager.getConnection(URL,USER,PASSWORD);
         }
         return conn;
    }

}
